<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.prime.com.tr/ui">

<ui:composition template="_empenho.xhtml">
	<ui:define name="corpo">

		<div id="conteudo">

			<h:form id="form"><br />

				<h2>
					<h:outputText value="CADASTRAR EMPENHO"
						rendered="#{empty empenhoBean.empenho.id}" />
					<h:outputText value="EDITAR EMPENHO"
						rendered="#{not empty empenhoBean.empenho.id}" />
				</h2>
				<hr /><br />

				<p:messages id="msg" />
				
				<p:fieldset legend="Dados do Empenho">
				<h:panelGrid columns="3">
				
				<h:outputLabel value="Número: " for="numero" />
				<p:inputText id="numero" value="#{empenhoBean.empenho.numero}" required="true" requiredMessage="Preencha o campo Número">
					<f:ajax event="change" />
				</p:inputText><br />
				
				<h:outputLabel value="Data de Emissão: " />
				<p:calendar value="#{empenhoBean.empenho.data.time}">
					<f:convertDateTime pattern="dd/MM/yyyy" timeZone="America/Sao_Paulo" />
				</p:calendar><br />
				
				<h:outputLabel value="Valor Total: " for="valor" />
				<p:inputText id="valor" value="#{empenhoBean.empenho.valor_total}">
					<f:convertNumber pattern="#,##0.00" />
				</p:inputText>
				<h:outputText value="Ex: 5.000,90" style="color: #00BFFF; font-weight:bold;" />		
				
				<h:outputLabel value="Interessado: " for="interessado" />
				<p:inputText id="interessado" value="#{empenhoBean.empenho.interessado}" style="width: 250px;">
					<f:ajax event="change" />
				</p:inputText><br />
				
				<h:outputLabel value="Fornecedor: " for="fornecedor" />
					<h:selectOneMenu value="#{empenhoBean.empenho.fornecedor}" converter="genericConverter">
						<f:selectItem itemLabel="::Selecione::" noSelectionOption="true" />
						<f:selectItems value="#{fornecedorBean.fornecedores}" var="fornecedor" itemLabel="#{fornecedor.nome}" itemValue="#{fornecedor}" />
				</h:selectOneMenu><br />	
				
				<h:outputLabel value="Processo: " for="processo" />
				<p:inputMask id="processo" value="#{empenhoBean.empenho.processo}" mask="99999.999999/9999-99" style="width: 250px;"
					required="true" requiredMessage="Preencha o campo Processo" >
					<f:ajax event="change" />
				</p:inputMask><br />
				
				<h:outputLabel value="Tipo: " for="tipo" />
				<h:selectOneMenu id="tipo" value="#{empenhoBean.empenho.tipo}" required="true" requiredMessage="Informorme o tipo do empenho" >
					<f:selectItem itemLabel="::Selecione::" noSelectionOption="true" />
					<f:selectItem itemLabel="Ordinário" itemValue="Ordinário" />
					<f:selectItem itemLabel="Global" itemValue="Global" />
					<f:selectItem itemLabel="Estimativo" itemValue="Estimativo" />
				</h:selectOneMenu><br />
								
				<h:outputLabel value="Status: " for="status" />
				<h:selectOneMenu id="status" value="#{empenhoBean.empenho.status}" required="true" requiredMessage="Qual o status do empenho?">
					<f:selectItem itemLabel="::Selecione::" noSelectionOption="true" />
					<f:selectItem itemLabel="Executado" itemValue="Executado" />
					<f:selectItem itemLabel="Entrega Parcial" itemValue="Entrega Parcial" />
					<f:selectItem itemLabel="Aguardando Entrega" itemValue="Aguardando Entrega" />
				</h:selectOneMenu><br />

				<p:commandButton id="grava" value="GRAVAR" action="#{empenhoBean.grava}" ajax="false" image="ui-icon-disk">
					<f:ajax render="@all" />
				</p:commandButton>	
				
				<p:button id="reset" type="reset" value="LIMPAR" rendered="#{empty empenhoBean.empenho.id}" />
				
				</h:panelGrid>
				</p:fieldset>
				
				</h:form>

			<p:dialog header="Empenhos" widgetVar="dlgEmpenho" model="true"
				width="1200" showEffect="hide">
				<h:form id="form1">

					<p:outputPanel id="empenhos">

						<p:dataTable id="listEmpenho" value="#{empenhoBean.empenhos}"
							onRowEditUpdate="#{empenhoBean.empenho}" var="empenho"
							paginator="true" selectionMode="single" rows="8"
							style="font-size: 11px" emptyMessage="Não Encontrado">

							<!--<p:ajax event="rowSelect" update="form" oncomplete="empeDialog.show()" />-->

							<f:facet name="header">
								<h:outputText value="EMPENHOS CADASTRADOS" />
							</f:facet>

							<p:column sortBy="#{empenho.numero}" filterBy="#{empenho.numero}"
								filterMatchMode="contains" headerText="Número"
								style="width: 150px;">
								<h:outputText value="#{empenho.numero}" />
							</p:column>

							<p:column sortBy="#{empenho.processo}"
								filterBy="#{empenho.processo}" filterMatchMode="contains"
								headerText="Processo" style="width: 200px;">
								<h:outputText value="#{empenho.processo}" />
							</p:column>

							<p:column sortBy="#{empenho.interessado}"
								headerText="Interessado">
								<h:outputText value="#{empenho.interessado}">
									<f:convertNumber type="currency" locale="pt_BR" />
								</h:outputText>
							</p:column>

							<p:column sortBy="#{empenho.tipo}" headerText="Tipo">
								<h:outputText value="#{empenho.tipo}" />
							</p:column>

							<p:column sortBy="#{empenho.status}" headerText="Status"
								style="width: 200px;">
								<h:outputText value="#{empenho.status}" />
							</p:column>


						</p:dataTable>

					</p:outputPanel>
				</h:form>
			</p:dialog>
		</div>


	</ui:define>
</ui:composition>
</html>